import java.util.Arrays;

class Solution {
    public int numSquares(int n) {
        int[] ret = new int[n+1];
        Arrays.fill(ret,0);
        for(int i=0;i<=n;i++) {
            ret[i]=i;
            for(int j=1;j*j<=i;j++) {
                ret[i]=Math.min(ret[i],ret[i-j*j]+1);
            }
        }
        return ret[n];
    }
}
public class lc279 {
}
